const state = {
	userInfo: null, //个人信息数据
	openid: '', //openid-唯一身份
	tel: '', //tel-手机号
	token: '', //teken-缓存密钥
	role: '', //登录角色
	operator: null, //登录的业务员信息
	switch_1: [],
	switch_2: [],
	switch_3: [],
	roleAlias: [],
	userList: [],
	menuNames: [],
	spotList: [],
}
const mutations = {
	SET_USERINFO: (state, userInfo) => {
		state.userInfo = userInfo;
	},
	SET_OPENID: (state, openid) => {
		state.openid = openid;
	},
	SET_TEL: (state, tel) => {
		state.tel = tel;
	},
	SET_TOKEN: (state, token) => {
		state.token = token;
	},
	SET_ROLE: (state, role) => {
		state.role = role;
	},
	SET_OPERATOR: (state, operator) => {
		state.operator = operator;
	},
	SET_SWITCH_1: (state, switch_1) => {
		state.switch_1 = switch_1;
	},
	SET_SWITCH_2: (state, switch_2) => {
		state.switch_2 = switch_2;
	},
	SET_SWITCH_3: (state, switch_3) => {
		state.switch_3 = switch_3;
	},
	SET_ROLEALIAS: (state, roleAlias) => {
		state.roleAlias = roleAlias;
	},
	SET_USERLIST: (state, uselist) => {
		state.userList = uselist;
	},
	SET_MENUNAMES: (state, menuNames) => {
		state.menuNames = menuNames;
	},
	SET_SPOTLIST: (state, spotList) => {
		state.spotList = spotList;
	},
}
const actions = {
	//初始化个人数据
	initUserInfo({
		commit
	}, data) {
		commit('SET_USERINFO', data);
		commit('SET_TOKEN', data.token);
		commit('SET_TEL', data.userPhone);
		commit('SET_OPENID', data.userPhone);
		commit('SET_SWITCH_1', data.roleAlias);
		commit('SET_SWITCH_2', data.uselist);
		commit('SET_SWITCH_3', data.menuNames);
		commit('SET_ROLEALIAS', data.roleAlias);
		commit('SET_USERLIST', data.uselist);
		commit('SET_MENUNAMES', data.menuNames);
		let operator = {};
		operator.workUserId = data.userId; //业务员组ID
		operator.userId = data.userId;
		operator.userName = data.userName;
		operator.stationId = data.stationId;
		operator.stationName = data.stationName;
		commit('SET_OPERATOR', operator);
	},
}
export default {
	state,
	mutations,
	actions
}